import { Space, Col, Row, Card, Menu } from "antd"
import { useState } from "react"
import { http } from "../../utils"
import '../student/index.scss'


function getItem (label, key, icon, items, type) {
  return {
    key,
    icon,
    items,
    label,
    type,
  }
}
const items = [
  getItem('进行中的考试', '1'),
  getItem('已完成的考试', '2'),
  getItem('已过期的考试', '3')
]

function StudentExam () {

  const [testList, setTestList] = useState([{

    "id": 23,
    "name": "第一份看起来像样子的试卷",
    "description": "这是关于《第一份看起来像样子的试卷》的描述",
    "status": 1,
    "subject_name": "小学数学",
    "total_score": 130,
    "test_time": 120,
    "start_time": "2022-09-04 09:25:46",
    "end_time": "2022-09-04 09:25:47",
    "judge_question_list": [{
      "answer": true,
      "description": null,
      "score": 5,
      "question_number": 1,
      "question_stem": "1+1=2"
    }, {
      "answer": false,
      "description": "1+2=3啊混蛋",
      "score": 5,
      "question_number": 2,
      "question_stem": "1+2=2"
    }],
    "gap_filling_question_list": [{
      "description": "2+2不等于4还能等于什么呢",
      "answer": ["4"],
      "score": 5,
      "question_number": 1,
      "question_stem": "2+2=_"
    }, {
      "description": "没错是爷爷",
      "answer": ["爷爷"],
      "score": 5,
      "question_number": 2,
      "question_stem": "爸爸的爸爸叫__"
    }],
    "single_select_question_list": [{
      "description": null,
      "item": ["A.纯路人", "B.小黑子", "C.ikun"],
      "answer": [0],
      "score": 10,
      "question_number": 1,
      "question_stem": "坤坤的真粉丝一般自称什么"
    }, {
      "description": null,
      "item": ["A.英文单词Control的缩写", "B.windows电脑键盘上的按键", "C.唱跳rap篮球"],
      "answer": [2],
      "score": 10,
      "question_number": 2,
      "question_stem": "请解释Ctrl的含义"
    }, {
      "description": null,
      "item": ["A.速度删除", "B.外国友人的名字", "C.大妈"],
      "answer": [0],
      "score": 10,
      "question_number": 3,
      "question_stem": "苏珊指的是什么"
    }, {
      "description": null,
      "item": ["A.绿色的尸体会散发出冷气", "B.绿色的僵尸害怕寒冷", "C.律师函"],
      "answer": [2],
      "score": 10,
      "question_number": 4,
      "question_stem": "绿尸寒指的是什么"
    }, {
      "description": null,
      "item": ["A.1,1", "B.2,2", "C.3,3", "D.1.5,0.5"],
      "answer": [0, 3],
      "score": 10,
      "question_number": 5,
      "question_stem": "_+_=2"
    }, {
      "description": null,
      "item": ["A.你", "B.我", "C.她", "D.他"],
      "answer": [2, 3],
      "score": 10,
      "question_number": 6,
      "question_stem": "你是谁"
    }],
    "multipart_select_question_list": [],
    "short_answer_question_list": [{
      "description": null,
      "answer": "答案就是,我也不懂为什么1+1会得出2",
      "score": 50,
      "question_number": 1,
      "question_stem": "请简述1+1=2的原因"
    }]
  }
  ])

  async function getExam () {
    const res = await http.get('/base_server/api/v1/pub/course/selected/list')
    console.log(res)
    setTestList(res.data)
  }
  const click = (e) => {
    console.log(e.key)
    getExam()
  }
  return (
    <div className="se-st">
      <Menu
        items={items}
        defaultSelectedKeys='1'
        onClick={click}
        className="head-sc"
        mode="horizontal"
      >
      </Menu>
      <Space >
        <Row
          gutter={{
            xs: 8,
            sm: 16,
            md: 24,
            lg: 32,
          }}
        >
          {testList.map((item, index) => {
            return (
              <Col span={6} key={item.id}>
                <Card title={item.name} style={{
                  width: 300,
                }}>
                  <span>{item.description}</span>
                  <span>{item.subject_name}</span>
                </Card>
              </Col>
            )
          })}
        </Row>
      </Space>

    </div>)
}

export default StudentExam

